package com.ucode.springboot.starter.ESsearch.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration
@EnableConfigurationProperties(ElasticsearchConfig.class)
public class ElasticsearchAutoConfiguration {

    @Autowired
    private ElasticsearchConfig elasticsearchProperties;

    @Bean(destroyMethod="close")
    @Scope("singleton")
    public RestHighLevelClientHelper restHighLevelClientHelper() {
        return new RestHighLevelClientHelper(elasticsearchProperties);
    }
}